﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Ciripescu_WebRole
{
    public partial class ShowError : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetExpires(new DateTime(1980, 11, 11));            
            Response.Cache.SetNoStore();
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetAllowResponseInBrowserHistory(false);

            if (Session["err"] == null)
            {
                divError.InnerHtml = "Nu stiu cum ai ajuns aici, dar nu a fost nici o eroare!";
                return;
            }
            string err = (string)Session["err"];
            divError.InnerHtml = err;
        }
        

        public static void ShowErrorMessage(string err, Page page)
        {
            page.Session.Add("err", err);
            page.Response.Redirect("/error/");
        }

        public static void ShowErrorMessage(string err, HttpContext context)
        {
            if(context.Session != null)
             context.Session.Add("err", err);
            context.Response.Redirect("/error/");
        }
    }
}
